<?php

namespace app\common\model;

use think\model\concern\SoftDelete;

class Member extends \think\Model
{
    use SoftDelete;

    protected $table = 'db_member';

    protected $jsonAssoc = true;

    protected $autoWriteTimestamp = true;

    protected $schema = [
        'id' => 'int',
        'create_time' => 'int',
        'update_time' => 'int',
        'delete_time' => 'int',
        'pubid' => 'varchar',
        'sort' => 'int',
        'name' => 'varchar',
        'phone' => 'varchar',
        'email' => 'varchar',
        'point_num' => 'double',
        'union_id' => 'varchar',
        'avatar' => 'varchar',
        'province' => 'varchar',
        'address' => 'varchar',
        'number_of_free_chats' => 'int',
        'chat_end_time' => 'int',
        'promoter_id' => 'int',
        'ref' => 'varchar',
        'mini_openid' => 'varchar',
        'official_openid' => 'varchar',
        'is_mobile_registration' => 'tinyint',
        'status' => 'tinyint',
    ];

    public $getters = [
        
    ];

    /**
     * 关联模型memberLoginLog
     */
    public function memberLoginLog()
    {
        return $this->hasMany(MemberLoginLog::class );
    }

    /**
     * 关联模型memberInformation
     */
    public function memberInformation()
    {
        return $this->hasOne(MemberInformation::class );
    }

    /**
     * 关联模型memberPointsLog
     */
    public function memberPointsLog()
    {
        return $this->hasMany(MemberPointsLog::class );
    }

    /**
     * 关联模型orders
     */
    public function orders()
    {
        return $this->hasMany(Orders::class );
    }

    /**
     * 关联模型articleTitle
     */
    public function articleTitle()
    {
        return $this->hasMany(ArticleTitle::class );
    }

    /**
     * 关联模型articleClass
     */
    public function articleClass()
    {
        return $this->hasMany(ArticleClass::class );
    }

    /**
     * 关联模型article
     */
    public function article()
    {
        return $this->hasMany(Article::class );
    }

    /**
     * 关联模型gptRequestLog
     */
    public function gptRequestLog()
    {
        return $this->hasMany(GptRequestLog::class );
    }

    /**
     * 关联模型imgClass
     */
    public function imgClass()
    {
        return $this->hasMany(ImgClass::class );
    }

    /**
     * 关联模型pushPlan
     */
    public function pushPlan()
    {
        return $this->hasMany(PushPlan::class );
    }

    /**
     * 关联模型pushLog
     */
    public function pushLog()
    {
        return $this->hasMany(PushLog::class );
    }

    /**
     * 关联模型site
     */
    public function site()
    {
        return $this->hasMany(Site::class );
    }

    /**
     * 关联模型copywritingMember
     */
    public function copywritingMember()
    {
        return $this->hasMany(CopywritingMember::class );
    }

    /**
     * 关联模型chatPromptMember
     */
    public function chatPromptMember()
    {
        return $this->hasMany(ChatPromptMember::class );
    }

    /**
     * 关联模型chatMessages
     */
    public function chatMessages()
    {
        return $this->hasMany(ChatMessages::class );
    }

    /**
     * 关联模型chat
     */
    public function chat()
    {
        return $this->hasMany(Chat::class );
    }

    /**
     * 关联模型memberBenefits
     */
    public function memberBenefits()
    {
        return $this->hasMany(MemberBenefits::class );
    }

    /**
     * 关联模型memberWithdrawal
     */
    public function memberWithdrawal()
    {
        return $this->hasMany(MemberWithdrawal::class );
    }

    /**
     * 关联模型chatVipRecords
     */
    public function chatVipRecords()
    {
        return $this->hasMany(ChatVipRecords::class );
    }

    /**
     * 关联模型articleTitleTask
     */
    public function articleTitleTask()
    {
        return $this->hasMany(ArticleTitleTask::class );
    }

    /**
     * 关联模型robot
     */
    public function robot()
    {
        return $this->hasMany(Robot::class );
    }

    /**
     * 关联模型newOrders
     */
    public function newOrders()
    {
        return $this->hasMany(NewOrders::class );
    }

    /**
     * 关联模型openaiUsage
     */
    public function openaiUsage()
    {
        return $this->hasMany(OpenaiUsage::class );
    }

    /**
     * 关联模型orderInvoice
     */
    public function orderInvoice()
    {
        return $this->hasMany(OrderInvoice::class );
    }

    /**
     * 关联模型templateMessageRecording
     */
    public function templateMessageRecording()
    {
        return $this->hasMany(TemplateMessageRecording::class );
    }

    /**
     * 聊天到期时间设置器
     */
    public function setChatEndTimeAttr($value, $data)
    {
        return $value?strtotime($value):0;
    }
}
